// 填充
import { fillPatternMap } from '../algorithm/fill.js'
import { _path2 } from "./path2.js";
import { _o } from '../math/index.js';
import { _taichiToSeg } from './curve.js'
import { _path } from "./svg.js"

const _taichi = (points) => {
    let o = _o(points)
    return _taichiToSeg(o, [points[0], points[1]])
}

export const _fill = (options, props) => {
    let { points = [], fill = {}, curve } = options
    let { pattern, inheritCurve = true } = fill

    if (pattern === 'taichi') {
        return _path(_taichi(points), {
            stroke: 'red',
            fill: 'none',
            ...props
        })
    }

    let fp = fillPatternMap({
        ...fill,
        points
    })


    return _path2({
        name: 'fill_' + pattern,
        curve: inheritCurve ? curve : 'none',
        ...fp
    }, props)

}
